package com.jingwee.springbootevtlistener.controller;

import com.jingwee.springbootevtlistener.event.MyEvent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.context.ApplicationContext;

@RestController
@RequestMapping("/evt")
public class EventController {

    @Autowired
    private ApplicationContext applicationContext;

    @GetMapping("/doEvent")
    public void doEvent(String event) {
        applicationContext.publishEvent(new MyEvent("[customer source]", event));
    }
}
